define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_seckill_edit(result){
			if(HTTP_ISLOGIC) {
				result = '{"success": true,"msg": "","result": { "act_id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
	function get_data_seckill_detail(result) {
            if(HTTP_ISLOGIC) {
                result ='{"success": true,"msg": "","result": { "act_id": "001", "name": "团购","start_time": "2017/01/01 09:00:00","end_time": "2017/01/31 09:00:00",'+
                '"create_group": true,"has_packets": true,"image": [{"id": "001","image": "img/upload/pro-img01.jpg"},{"id": "002","image": "img/upload/pro-img01.jpg"}],"brand_id": "001","brand_name": "博朗","cat_type": [{"id": "001","name": "工具类-扳手类-家用扳手"},{"id": "002","name": "工具类-扳手类-家用扳手" }]'+
                '},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
   			 return JSON.parse(result);
            } else {
                return result;
            }
        }
	
	function get_data_seckill_dealer(result) {
            if(HTTP_ISLOGIC) {
                result ='{"success":true,"msg":"","result":{"region":[{"region_id":"001","region_name":"江苏","is_all":false,"store":[{"store_id":"001","store_name":"世达"},{"store_id":"002","store_name":"博士"}]},{"region_id":"002","region_name":"浙江","is_all":true,"store":[{"store_id":"003","store_name":"益达"},{"store_id":"004","store_name":"飞达"}]}],"goods":[{"goods_id":"001","goods_name":"一字螺丝刀","limit_buy_num":10,"count":200,"image":"img/upload/pro-img01.jpg","seckill_price":8,"price":10,"prize_price":5},{"goods_id":"002","goods_name":"十字螺丝刀","count":1000,"limit_buy_num":10,"image":"img/upload/pro-img01.jpg","price":10,"seckill_price":8,"prize_price":5}],"change_price":false},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
   			 return JSON.parse(result);
            } else {
                return result;
            }
        }

		//返回信息
		return {
				seckill_detail: function(act_id,callback) {
                Http.post({
                        method: 'marketing.seckill.detail',
                        act_id:act_id
                    },
                    function(result) {
                        //请求成功
                        if(callback)
                            callback(get_data_seckill_detail(result).result);
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
           },
           seckill_dealer: function(act_id,callback) {
                Http.post({
                        method: 'marketing.seckill.dealer',
                        act_id:act_id
                    },
                    function(result) {
                        //请求成功
                        if(callback)
                            callback(get_data_seckill_dealer(result).result);
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
           },
			 seckill_edit: function(act_id,region,goods,callback) {
			 	var updateParams = new Object();
				updateParams.act_id = act_id;
				updateParams.region = region;
				updateParams.goods = goods;
				updateParams = JSON.stringify(updateParams);	
                Http.post({
                        method: 'marketing.seckill.agenterjion',
                        updateParams:updateParams
                       
                        
                    },
                    function(result) {
                    	if(callback)
                    	callback(get_data_seckill_edit(result));
                    },
                    function(e) {
                        //请求异常
                    },
                    function() {
                        //请求完成，一般不做什么事情
                    });
           }
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Groupseckill_agent", factory);
});